import java.util.*;

class StringList {
    public static void main( String[] args )
    {
        List<String> animals = new ArrayList<String>();               
        animals.add( "cheetah" );                                 
        animals.add( "lion" );                            
        animals.add( "cat" );           
        animals.add( "fox" );           
        animals.add( "cat" );           //duplicate cat           
        System.out.println( animals );  
        // [cheetah, lion, cat, fox, cat]

        animals.remove( "lion" );                                 
        System.out.println( animals );  
        // [cheetah, cat, fox, cat]

        animals.add( 0, "lion" );                                 
        System.out.println( animals ); 
        // [lion, cheetah, cat, fox, cat]

        animals.add( 3, "racoon" );                               
        System.out.println( animals );   
        // [lion, cheetah, cat, racoon, fox, cat]

        animals.remove(3);                                        
        System.out.println( animals ); 
        // [lion, cheetah, cat, fox, cat]

        Collections.sort( animals );                              
        System.out.println( animals );  
        // [cat, cat, cheetah, fox, lion]

        ListIterator iter = animals.listIterator();               
        while ( iter.hasNext() ) {                                
        	System.out.println( iter.next()  );                   
        }
        /*
          	cat
			cat
			cheetah
			cat
			dog
			bird
			fox
			lion
         */
    }
}
